package logic

import (
	"2210a/vipshop/vipshoprpc/vipshoprpc"
	"context"

	"2210a/vipshop/vipshopapi/internal/svc"
	"2210a/vipshop/vipshopapi/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserPerfectLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUserPerfectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserPerfectLogic {
	return &UserPerfectLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserPerfectLogic) UserPerfect(req *types.UserPerfectRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	perfect, err := l.svcCtx.VipshopRpc.UserPerfect(l.ctx, &vipshoprpc.UserPerfectRequest{
		Id:          req.Id,
		Age:         req.Age,
		NativePlace: req.NativePlace,
		Email:       req.Email,
		Avatar:      req.Avatar,
	})
	if err != nil {
		return &types.Response{
			Code:    500,
			Message: err.Error(),
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Code:    200,
		Message: "完善信息成功",
		Data:    perfect.Id,
	}, nil
}
